package com.cy.facade;

import java.util.Random;

/**
 * <br>@class: FacadeTest
 * <br>@description: 门面模式
 * <br>@author: cy
 * <br>@date: 2020-03-29 14:20:02
 * <br>@version: 1.0
 * <br>
 * <br>@since: (版本) 作者 时间 注释
 */
public class FacadeTest {
    public static void main(String[] args) {
     //为子系统中的一组接口提供一个一致的接口，facade模式定义了一个高层接口，这个接口使得这一子系统更加容易使用
        FacadeReadAndWrite facadeReadAndWrite = new FacadeReadAndWrite();
        facadeReadAndWrite.doSomeThing();
    }
}
interface IRead{
    String readSomething ();
}
class ReadImpl implements IRead{

    @Override
    public String readSomething() {
        return "read ok";
    }
}
interface IWrite{
    void writeSomething(String str);
}
class WriteImpl implements IWrite{

    @Override
    public void writeSomething(String str) {
        System.out.println("Write ok");
    }
}
class FacadeReadAndWrite {
    IRead r = new ReadImpl();
    IWrite w = new WriteImpl();
    public void doSomeThing(){
        r.readSomething();
        w.writeSomething("ok");
    }

}